%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/relation-tail-head"
    Bucket0("Bucket 0 (root)<br /><br />1: 68, 72, 76, 80<br />ᐳ: Access[9], Access[10], Object[11]<br />2: PgSelect[8], PgSelect[15]<br />ᐳ: 69, 73, 77, 81<br />3: Connection[12], Connection[17]<br />4: 19, 22"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 19, 69, 73<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 17, 22, 77, 81<br /><br />ROOT Connectionᐸ15ᐳ[17]"):::bucket
    Bucket5("Bucket 5 (listItem)<br />Deps: 69, 73<br /><br />ROOT __Item{5}ᐸ19ᐳ[25]"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 77, 81<br /><br />ROOT __Item{6}ᐸ22ᐳ[27]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 26, 69, 73<br /><br />ROOT PgSelectSingle{5}ᐸcompound_keyᐳ[26]<br />1: <br />ᐳ: 29, 31, 33, 70, 74, 71, 75<br />2: PgSelectRows[40], PgSelectRows[52]<br />ᐳ: 39, 41, 51, 53"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 28, 77, 81<br /><br />ROOT PgSelectSingle{6}ᐸforeign_keyᐳ[28]<br />1: <br />ᐳ: 30, 32, 34, 78, 82, 79, 83<br />2: PgSelectRows[47], PgSelectRows[57]<br />ᐳ: 46, 48, 56, 58"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 41<br /><br />ROOT PgSelectSingle{7}ᐸpersonᐳ[41]"):::bucket
    Bucket10("Bucket 10 (nullableBoundary)<br />Deps: 48<br /><br />ROOT PgSelectSingle{8}ᐸpersonᐳ[48]"):::bucket
    Bucket11("Bucket 11 (nullableBoundary)<br />Deps: 53<br /><br />ROOT PgSelectSingle{7}ᐸpersonᐳ[53]"):::bucket
    Bucket12("Bucket 12 (nullableBoundary)<br />Deps: 58<br /><br />ROOT PgSelectSingle{8}ᐸcompound_keyᐳ[58]"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2
    Bucket1 --> Bucket5
    Bucket2 --> Bucket6
    Bucket5 --> Bucket7
    Bucket6 --> Bucket8
    Bucket7 --> Bucket9 & Bucket11
    Bucket8 --> Bucket10 & Bucket12

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸcompound_keyᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgSelectInlineApply68["PgSelectInlineApply[68∈0] ➊"]:::plan
    PgSelectInlineApply72["PgSelectInlineApply[72∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply68 & PgSelectInlineApply72 --> PgSelect8
    PgSelect15[["PgSelect[15∈0] ➊<br />ᐸforeign_keyᐳ"]]:::plan
    PgSelectInlineApply76["PgSelectInlineApply[76∈0] ➊"]:::plan
    PgSelectInlineApply80["PgSelectInlineApply[80∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply76 & PgSelectInlineApply80 --> PgSelect15
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection12
    Connection17[["Connection[17∈0] ➊<br />ᐸ15ᐳ"]]:::plan
    PgSelect15 --> Connection17
    ConnectionItems19[["ConnectionItems[19∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems19
    ConnectionItems22[["ConnectionItems[22∈0] ➊"]]:::plan
    Connection17 --> ConnectionItems22
    Access69{{"Access[69∈0] ➊<br />ᐸ8.m.joinDetailsFor35ᐳ"}}:::plan
    PgSelect8 --> Access69
    Access73{{"Access[73∈0] ➊<br />ᐸ8.m.joinDetailsFor49ᐳ"}}:::plan
    PgSelect8 --> Access73
    Access77{{"Access[77∈0] ➊<br />ᐸ15.m.joinDetailsFor42ᐳ"}}:::plan
    PgSelect15 --> Access77
    Access81{{"Access[81∈0] ➊<br />ᐸ15.m.joinDetailsFor54ᐳ"}}:::plan
    PgSelect15 --> Access81
    __Item25[/"__Item[25∈5]<br />ᐸ19ᐳ"\]:::itemplan
    ConnectionItems19 ==> __Item25
    PgSelectSingle26{{"PgSelectSingle[26∈5]<br />ᐸcompound_keyᐳ"}}:::plan
    __Item25 --> PgSelectSingle26
    __Item27[/"__Item[27∈6]<br />ᐸ22ᐳ"\]:::itemplan
    ConnectionItems22 ==> __Item27
    PgSelectSingle28{{"PgSelectSingle[28∈6]<br />ᐸforeign_keyᐳ"}}:::plan
    __Item27 --> PgSelectSingle28
    List70{{"List[70∈7]<br />ᐸ69,26ᐳ"}}:::plan
    Access69 & PgSelectSingle26 --> List70
    List74{{"List[74∈7]<br />ᐸ73,26ᐳ"}}:::plan
    Access73 & PgSelectSingle26 --> List74
    PgClassExpression29{{"PgClassExpression[29∈7]<br />ᐸ__compound...rson_id_1”ᐳ"}}:::plan
    PgSelectSingle26 --> PgClassExpression29
    PgClassExpression31{{"PgClassExpression[31∈7]<br />ᐸ__compound...rson_id_2”ᐳ"}}:::plan
    PgClassExpression29 o--o PgClassExpression31
    PgClassExpression33{{"PgClassExpression[33∈7]<br />ᐸ__compound...__.”extra”ᐳ"}}:::plan
    PgClassExpression31 o--o PgClassExpression33
    First39{{"First[39∈7]"}}:::plan
    PgSelectRows40[["PgSelectRows[40∈7]"]]:::plan
    PgSelectRows40 --> First39
    Lambda71{{"Lambda[71∈7]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda71 --> PgSelectRows40
    PgSelectSingle41{{"PgSelectSingle[41∈7]<br />ᐸpersonᐳ"}}:::plan
    First39 --> PgSelectSingle41
    First51{{"First[51∈7]"}}:::plan
    PgSelectRows52[["PgSelectRows[52∈7]"]]:::plan
    PgSelectRows52 --> First51
    Lambda75{{"Lambda[75∈7]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda75 --> PgSelectRows52
    PgSelectSingle53{{"PgSelectSingle[53∈7]<br />ᐸpersonᐳ"}}:::plan
    First51 --> PgSelectSingle53
    List70 --> Lambda71
    List74 --> Lambda75
    List78{{"List[78∈8]<br />ᐸ77,28ᐳ"}}:::plan
    Access77 & PgSelectSingle28 --> List78
    List82{{"List[82∈8]<br />ᐸ81,28ᐳ"}}:::plan
    Access81 & PgSelectSingle28 --> List82
    PgClassExpression30{{"PgClassExpression[30∈8]<br />ᐸ__foreign_...person_id”ᐳ"}}:::plan
    PgSelectSingle28 --> PgClassExpression30
    PgClassExpression32{{"PgClassExpression[32∈8]<br />ᐸ__foreign_...und_key_1”ᐳ"}}:::plan
    PgClassExpression30 o--o PgClassExpression32
    PgClassExpression34{{"PgClassExpression[34∈8]<br />ᐸ__foreign_...und_key_2”ᐳ"}}:::plan
    PgClassExpression32 o--o PgClassExpression34
    First46{{"First[46∈8]"}}:::plan
    PgSelectRows47[["PgSelectRows[47∈8]"]]:::plan
    PgSelectRows47 --> First46
    Lambda79{{"Lambda[79∈8]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda79 --> PgSelectRows47
    PgSelectSingle48{{"PgSelectSingle[48∈8]<br />ᐸpersonᐳ"}}:::plan
    First46 --> PgSelectSingle48
    First56{{"First[56∈8]"}}:::plan
    PgSelectRows57[["PgSelectRows[57∈8]"]]:::plan
    PgSelectRows57 --> First56
    Lambda83{{"Lambda[83∈8]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda83 --> PgSelectRows57
    PgSelectSingle58{{"PgSelectSingle[58∈8]<br />ᐸcompound_keyᐳ"}}:::plan
    First56 --> PgSelectSingle58
    List78 --> Lambda79
    List82 --> Lambda83
    PgClassExpression59{{"PgClassExpression[59∈9]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgSelectSingle41 --> PgClassExpression59
    PgClassExpression63{{"PgClassExpression[63∈9]<br />ᐸ__person__.”email”ᐳ"}}:::plan
    PgClassExpression59 o--o PgClassExpression63
    PgClassExpression60{{"PgClassExpression[60∈10]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgSelectSingle48 --> PgClassExpression60
    PgClassExpression64{{"PgClassExpression[64∈10]<br />ᐸ__person__.”email”ᐳ"}}:::plan
    PgClassExpression60 o--o PgClassExpression64
    PgClassExpression61{{"PgClassExpression[61∈11]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgSelectSingle53 --> PgClassExpression61
    PgClassExpression65{{"PgClassExpression[65∈11]<br />ᐸ__person__.”email”ᐳ"}}:::plan
    PgClassExpression61 o--o PgClassExpression65
    PgClassExpression62{{"PgClassExpression[62∈12]<br />ᐸ__compound...rson_id_1”ᐳ"}}:::plan
    PgSelectSingle58 --> PgClassExpression62
    PgClassExpression66{{"PgClassExpression[66∈12]<br />ᐸ__compound...rson_id_2”ᐳ"}}:::plan
    PgClassExpression62 o--o PgClassExpression66
    PgClassExpression67{{"PgClassExpression[67∈12]<br />ᐸ__compound...__.”extra”ᐳ"}}:::plan
    PgClassExpression66 o--o PgClassExpression67

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,PgSelect15,Connection17,ConnectionItems19,ConnectionItems22,PgSelectInlineApply68,Access69,PgSelectInlineApply72,Access73,PgSelectInlineApply76,Access77,PgSelectInlineApply80,Access81 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2 bucket2
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item25,PgSelectSingle26 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item27,PgSelectSingle28 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression29,PgClassExpression31,PgClassExpression33,First39,PgSelectRows40,PgSelectSingle41,First51,PgSelectRows52,PgSelectSingle53,List70,Lambda71,List74,Lambda75 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,PgClassExpression30,PgClassExpression32,PgClassExpression34,First46,PgSelectRows47,PgSelectSingle48,First56,PgSelectRows57,PgSelectSingle58,List78,Lambda79,List82,Lambda83 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression59,PgClassExpression63 bucket9
    classDef bucket10 stroke:#ffff00
    class Bucket10,PgClassExpression60,PgClassExpression64 bucket10
    classDef bucket11 stroke:#00ffff
    class Bucket11,PgClassExpression61,PgClassExpression65 bucket11
    classDef bucket12 stroke:#4169e1
    class Bucket12,PgClassExpression62,PgClassExpression66,PgClassExpression67 bucket12

